package com.tim.ying.tree.binary;

import com.tim.ying.tree.node.TreeNode;
import com.tim.ying.tree.util.TreeUtils;

/**
 * 二叉树操作
 * @author yingbibo
 *
 */
public class BinaryTree {
	
	public static void main(String[] args) {
		TreeNode t = createTree();
		System.out.println(TreeUtils.height(t));
		System.out.println(TreeUtils.size(t));
		TreeUtils.preOrder(t);
		System.out.println();
		TreeUtils.lastOrder(t);
		System.out.println();
		TreeUtils.midOrder(t);
		System.out.println("ok");
	}
	/**
	 * 初始化一棵树
	 * @return
	 */
	public static TreeNode createTree(){
		TreeNode root = new TreeNode("root", 0);
		TreeNode bNode = new TreeNode("b", 0);
		TreeNode cNode = new TreeNode("c", 0);
		TreeNode dNode = new TreeNode("d", 0);
		TreeNode eNode = new TreeNode("e", 0);
		TreeNode fNode = new TreeNode("f", 0);
		root.left = bNode;
		root.right = cNode;
		root.left.left = dNode;
		root.left.right = eNode;
		root.right.right = fNode;
		return root;
	}
	
	
	
}
